package com.exsun.ex1077.ui.activity.launch

import android.os.Bundle
import com.amap.api.maps.MapsInitializer
import com.blankj.utilcode.util.AppUtils
import com.exsun.ex1077.R
import com.exsun.ex1077.databinding.ActivityLaunchBinding
import com.exsun.ex1077.network.ApiUrl
import com.exsun.ex1077.ui.activity.login.LoginActivity
import com.zhangping.amap.LocationHelper
import com.zhangping.fastjetpack.base.BaseActivity
import com.zhangping.fastjetpack.base.BaseViewModel
import com.zhangping.fastjetpack.base.appContext
import com.zhangping.fastjetpack.callback.CommonCallback
import com.zhangping.fastjetpack.extend.*
import com.zhangping.fastjetpack.ui.popup.SimplePrivacyPopup
import kotlinx.android.synthetic.main.activity_launch.*

/**
 * 描述：
 * 作者：ZhangPing
 * 创建时间：2023/2/8 16:38
 */
class LaunchActivity: BaseActivity<BaseViewModel, ActivityLaunchBinding>() {

    override fun initView(savedInstanceState: Bundle?) {
        val hasShowGuide = getCacheBoolean("hasShowGuide")
        if (isAgreePrivacy()){
            if (hasShowGuide) toActivity<LoginActivity>(finish = true) else toActivity<GuideActivity>(finish = true)
            return
        }
        super.initView(savedInstanceState)
        showCustom(SimplePrivacyPopup(this, ApiUrl.PRIVACY_AGREEMENT, R.color.color_3D73FF, object : CommonCallback{
            override fun onCall() {
                updateAgreePrivacy(true)
                //初始化高德地图
                MapsInitializer.updatePrivacyShow(appContext, true, true)
                MapsInitializer.updatePrivacyAgree(appContext, true)
                LocationHelper.init(appContext)
                postDelayed(1000){
                    if (hasShowGuide) toActivity<LoginActivity>(finish = true) else toActivity<GuideActivity>(finish = true)
                }
            }
        }))
    }

}